package CollectionsText;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.TreeSet;

public class Landlords {
    public static void main(String[] args) {
        LinkedHashMap<Integer,String> link = new LinkedHashMap<>();
        String[] colour = {"♣","♦","♥","♠"};
        String[] number = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        ArrayList<Integer> list = new ArrayList<>();
        int count=0;
        for (String s : number) {
            for (String s1 : colour) {
                String value = s1+s;
                link.put(count,value);
                list.add(count);
                count++;
            }
        }
        link.put(count,"大王");
        list.add(count);
        count++;
        link.put(count,"小王");
        list.add(count);
        //洗牌
        Collections.shuffle(list);
        //玩家数量
        TreeSet<Integer> tree1 = new TreeSet<>();
        TreeSet<Integer> tree2 = new TreeSet<>();
        TreeSet<Integer> tree3 = new TreeSet<>();
        //底牌
        TreeSet<Integer> diPai = new TreeSet<>();
        for (int i = 0; i < list.size()-3; i++) {
            if(i%3==0) {
                tree1.add(list.get(i));
            } else if(i%3==1) {
                tree2.add(list.get(i));
            } else if(i%3==2) {
                tree3.add(list.get(i));
            }
        }
        diPai.add(list.get(51));
        diPai.add(list.get(52));
        diPai.add(list.get(53));
        look(tree1,link,"于飞正");
        look(tree2,link,"杨昊");
        look(tree3,link,"陈志伟");
        look(diPai,link,"底牌");
    }
    public static void look(TreeSet<Integer> tree,LinkedHashMap<Integer,String> link,String name) {
        System.out.println(name+"的牌是：");
        for (Integer integer : tree) {
            String s = link.get(integer);
            System.out.print(s);
        }
        System.out.println( );
    }
}
